package com.xxxx.server.controller;


import com.xxxx.server.pojo.Department;
import com.xxxx.server.pojo.RespBean;
import com.xxxx.server.service.IDepartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *
 * 前端控制器
 * </p>
 *
 * @author zhoubin
 */
@RestController
@RequestMapping("/system/basic/department")
public class DepartmentController {

	@Autowired
	private IDepartmentService departmentService;

	@GetMapping("/")
	public List<Department> selectdepartment(String depname){
		List<Department> list= departmentService.selectDepart(depname);

	/*	Department a= list.get(0);
		System.out.println(a);*/

		return list;
	}


/*	@RequestMapping()
	public List<Department> selectDepartmentAll(){
		return departmentService.selectDepartmentAll();
	}
	*/


	@PostMapping("/")
	public RespBean addDepartment(@RequestBody Department department){
		System.out.println(department.getName()+department.getParentId());
		return departmentService.addDepart(department);
	}

	@DeleteMapping("/{id}")
	public RespBean deletDepartment(@PathVariable String id){
		System.out.println(id);
		return departmentService.deletDepart(id);
	}




}
